a = input("Введите скобочную последовательность:")
qq = []
t = True
for i in a:
    if i in '({[':
        qq.append(i)
    elif i in ')}]':
        if not qq:
            t = False
            break
        op = qq.pop()
        if op == '(' and i == ")":
            continue
        if op == '{' and i == "}":
            continue
        if op == '[' and i == "]":
            continue

        t = False
        break
if t and len(qq) == 0:
    print('True')
else:
    print("False")
